Ubuntu 12.04
Sponsored Link

Basic Auth + PAM
2012/07/10
 
Configure httpd and set a page that people must authenticate and the authentication is from PAM.
[1] Install mod-auth-external and pwauth.
root@www:~#
aptitude -y install libapache2-mod-authnz-external pwauth
root@www:~#
a2enmod authnz_external

Enabling module authnz_external.
Run '/etc/init.d/apache2 restart' to activate new configuration!
[root@www ~]#
vi /etc/httpd/conf.d/auth_pam.conf
# for example, users must authenticate under /var/www/html/test

AddExternalAuth pwauth /usr/sbin/pwauth
SetExternalAuthMethod pwauth pipe
<Directory /var/www/test>
    SSLRequireSSL
    AuthType Basic
    AuthName "PAM Authentication"
    AuthBasicProvider external
    AuthExternal pwauth
    require valid-user
</Directory>

root@www:~#
service apache2 restart

* Restarting web server apache2
... waiting ...done.
# create a test page

[root@www ~]#
vi /var/www/html/test/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for PAM Auth
</div>
</body>
</html>
  Access to the test page with web browser, then authentication is required as a config. Input a user in local /etc/passwd and authenticate here.
  Just accessed.
 
Tweet